#include "commandPool.h"

commandPool::commandPool(void)
{
	cout<<"commands init ++"<<std::endl;
	dict.insert( std::make_pair( 'ST', new processStartCommand ) );
	dict.insert( std::make_pair( 'SP', new processStopCommand ) );
	cout<<"commands init ok"<<std::endl;

}


commandPool::~commandPool(void)
{
	cout<<"commands deleting-------------"<<std::endl;
	while( dict.begin() != dict.end() )
	{
		delete dict.begin()->second;
		dict.erase( dict.begin() );
	}
	cout<<"commands deleted-------------"<<std::endl;



}

commandBase* commandPool::lookup( char x)
{
	std::map<char, commandBase*>::const_iterator iter;
	iter = dict.find( toupper(x) );
	if( iter != dict.end() )
		return iter->second;
	else
		return NULL;

}